#region Namespace References

using System;
using DynConDevCorp.OpenArch.SmartData.BillingDemo1.ApplicationBusinessObjects;
using DynConDevCorp.OpenArch.SmartData.Core;
using DynConDevCorp.OpenArch.SmartData.Interfaces.Attributes;
using DynConDevCorp.OpenArch.SmartData.WinForms;

#endregion

namespace DynConDevCorp.OpenArch.SmartData.BillingDemo1.SmartUIControls
{
    public partial class OrderDetailControl : SmartEntityControl
    {
        #region Constructors

        public OrderDetailControl()
        {
            InitializeComponent();
            EntityBindingManager.BoundEntityChanged += EntityBindingManager_BoundEntityChanged;
            OrderDetail = new SmartEntityLink<OrderDetail>();
            OrderDetail.LinkedEntityChanged += OrderDetail_LinkedEntityChanged;
        }

        #endregion

        #region Public Instance Properties

        [AutoField]
        public SmartEntityLink<OrderDetail> OrderDetail { get; set; }

        #endregion

        #region Public Instance Methods

        public void OrderDetail_LinkedEntityChanged(object sender, EventArgs e)
        {
            bmcOrderDetail.BoundEntity = OrderDetail.LinkedEntity;
        }

        #endregion

        #region Private Instance Methods

        private void EntityBindingManager_BoundEntityChanged(object sender, EventArgs e)
        {
            OrderDetail entity = EntityBindingManager.BoundEntity as OrderDetail;
            OrderDetail.LinkedEntity = entity;
        }

        #endregion
    }
}